home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Programming Stuff / Sample Code / DTS Sample Code / MyCaptureApp ƒ 1.0b4 / MyUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-28  |  2.8 KB  |  131 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        MySGStuff.c
  3.     
  4.     Contains:    Sequence grabber code.
  5.  
  6.     Written by:    John Wang
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <1>        04/04/94    JW        Created.
  13.  
  14.     To Do:
  15.     
  16. */
  17.  
  18. #ifdef THINK_C
  19. #define        applec
  20. #endif
  21. #include    "MyHeaders"
  22. /*
  23. #include    <Types.h>
  24. #include    <Memory.h>
  25. #include    <QuickDraw.h>
  26. #include    <Palettes.h>
  27. #include    <QDOffscreen.h>
  28. #include    <Errors.h>
  29. #include    <Fonts.h>
  30. #include    <Dialogs.h>
  31. #include    <Windows.h>
  32. #include    <Menus.h>
  33. #include    <Events.h>
  34. #include    <Desk.h>
  35. #include    <DiskInit.h>
  36. #include    <OSUtils.h>
  37. #include    <Resources.h>
  38. #include    <ToolUtils.h>
  39. #include    <AppleEvents.h>
  40. #include    <EPPC.h>
  41. #include    <GestaltEqu.h>
  42. #include    <Processes.h>
  43. #include    <Balloons.h>
  44. #include    <Aliases.h>
  45. #include    <MixedMode.h>
  46. #include    <Scrap.h>
  47. #include    <LowMem.h>
  48. */
  49. #include    <Folders.h>
  50.  
  51. #include    "MyCaptureAppShell.h"
  52. #include    "MySGStuff.h"
  53. #include    "MyUtils.h"
  54.  
  55. /* ------------------------------------------------------------------------- */
  56.  
  57. //    Show Alert.  Then, return true is err != noErr.
  58. void ReportWarning(Str255 procStr, long err)
  59. {
  60.     Str255    myStr;
  61.     
  62.     NumToString(err, myStr);
  63.     ParamText("\pWarning!", procStr, err ? myStr : nil, nil);
  64.     Alert(kALERT_ERROR, nil);
  65. }
  66.  
  67. void ReportFatal(Str255 procStr, long err)
  68. {
  69.     Str255    myStr;
  70.     
  71.     NumToString(err, myStr);
  72.     ParamText("\pFatal Error!", procStr, err ? myStr : nil, nil);
  73.     Alert(kALERT_ERROR, nil);
  74.     ExitToShell();
  75. }
  76.  
  77. void GetGlobalWindow(WindowPtr theWindow, Rect *windowRect)
  78. {
  79.     //    Get the windowRect in global coordinates.
  80.     *windowRect = theWindow->portRect;
  81.     LocalToGlobal(&topLeft(*windowRect));
  82.     LocalToGlobal(&botRight(*windowRect));
  83. }
  84.  
  85. /* ------------------------------------------------------------------------- */
  86.  
  87. //    readPreferencesFile will return refnum = -1 if not found.
  88. short readPreferencesFile()
  89. {
  90.     short            myVRefNum;
  91.     long            myDirID;
  92.     StringHandle    prefsName;
  93.     short            myRefNum;
  94.     
  95.     if (FindFolder(kOnSystemDisk, kPreferencesFolderType, true, &myVRefNum, &myDirID))
  96.         return(-1);
  97.     
  98.     prefsName = GetString(STR_PREFSNAME);
  99.     myRefNum = HOpenResFile(myVRefNum, myDirID, (unsigned char *) *prefsName, fsRdPerm);
  100.     ReleaseResource((Handle) prefsName);
  101.     
  102.     return(myRefNum);
  103. }
  104.  
  105. //    writePreferencesFile returns -1 if preferences file can't be opened.
  106. short writePreferencesFile()
  107. {
  108.     short            myVRefNum;
  109.     long            myDirID;
  110.     StringHandle    prefsName;
  111.     short            myRefNum;
  112.     
  113.     if (FindFolder(kOnSystemDisk, kPreferencesFolderType, true, &myVRefNum, &myDirID))
  114.         return(-1);
  115.     
  116.     prefsName = GetString(STR_PREFSNAME);
  117.     HDelete(myVRefNum, myDirID, (unsigned char *) *prefsName);
  118.     HCreateResFile(myVRefNum, myDirID, (unsigned char *) *prefsName);
  119.     myRefNum = HOpenResFile(myVRefNum, myDirID, (unsigned char *) *prefsName, fsRdWrPerm);
  120.     ReleaseResource((Handle) prefsName);
  121.     
  122.     return(myRefNum);
  123. }
  124.  
  125. void closePreferencesFile(short myRefNum)
  126. {
  127.     UpdateResFile(myRefNum);
  128.     CloseResFile(myRefNum);
  129. }
  130.  
  131.